<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>

<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                        <div class="row">
                            <div class="col-xs-12">
                                <form accept-charset="UTF-8" id="new_add" action="<?php echo site_url(X_URL.'orders/delivers/'.$id);?>" class="form-horizontal" role="form" method="post" novalidate="novalidate">
                                <?php echo csrf_hidden();?>
                                    <div class="space-4"></div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label no-padding-right" for="deliver_no"> 快递单号 </label>
                                        <div class="col-sm-9">
                                            <input type="text" id="deliver_no" name="deliver_no" placeholder="快递单号" class="col-xs-10 col-sm-5" value="">
                                            <span class="help-block col-sm-reset inline col-xs-12 col-sm-7 hidden-480">快递单号数字</span>
                                        </div>
                                    </div>
                                    <div class="space-4"></div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label no-padding-right" for="deliver_company"> 快递公司 </label>
                                        <div class="col-sm-1">
                                            <select name="deliver_company" id="deliver_company" class="select2" size="1">
                                                <option value="0">请选择物流公司</option>
                                                <?php if(isset($delivers) && !empty($delivers)){ ?>
                                                <?php foreach ($delivers as $key =>$val ) { ?>
                                                <option value="<?php echo $val['id'];?>" ><?php echo $val['deliver_name'];?></option>
                                                <?php }?>
                                                <?php }?>
                                            </select>
                                        </div>
                                    </div>                              
                                    
                                    <div class="clearfix form-actions">
                                        <div class="col-md-offset-3 col-md-9">
                                            <button class="btn btn-info" type="submit" id="submit">
                                                <i class="ace-icon fa fa-check bigger-110"></i>
                                                确认发货
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div><!-- /.main-content -->

            <?php $this->load->view('common/footer');?>

            <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
                <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
            </a>
        </div><!-- /.main-container -->
        <?php $this->load->view('common/footerjs');?>
        <!-- inline scripts related to this page -->
        </body>
        </html>
        <script type="text/javascript">
            $("#submit").click(function () {
            var deliver_no = $("#deliver_no").val();
            var deliver_company = $("#deliver_company").val();
            
            if (deliver_no == '') {
                bootbox.dialog({
                    title : "系统提示",
                    message: "抱歉，快递单号不能为空。",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }
            
            if (deliver_company == 0) {
                bootbox.dialog({
                    title :"系统提示",
                    message: "快递公司不能为空",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }
            $("#new_add").submit();

        })
        </script>